﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using Bussiness.InternetBanking;
using FOModels.InternetBanking;
using Bussiness.Company;
using FOModels.Company;
using Bussiness.Language;
using FOModels.Language;
using System.Net;
using FOSystem.CultureHelper;
using Bussiness.Product;
using FOModels.Product;
using Bussiness.ProductFAQ;
using FOModels.ProductFAQ;
using Bussiness.Status;
using FOModels.Status;
using System.Configuration;
using System.Net.Mail;
namespace FO.Controllers
{
    public class InternetBankingController : CultureController
    {
        //
        // GET: /InternetBanking/

        public ActionResult Index()
        {
            InternetBankingBLL cardbll = new InternetBankingBLL();
            LanguageBLL langbll = new LanguageBLL();
            Language lang = langbll.getLangByCode(Request.Cookies["_culture"]["lang"]);
            ProductBLL probll = new ProductBLL();
            int InternetBankingID = int.Parse(System.Configuration.ConfigurationManager.AppSettings["InternetBankingID"].ToString());
            ViewBag.InternetBanking = cardbll.getInternetBankingList(lang.LangID);
            ViewBag.ProDes = probll.getProductByID(InternetBankingID, lang.LangID);
            return View();
        }
        public ActionResult InternetBankingInfo(int InternetBankingID)
        {
            InternetBankingBLL cardbll = new InternetBankingBLL();
            LanguageBLL langbll = new LanguageBLL();
            ProductFAQBLL faqbll = new ProductFAQBLL();
            Language lang = langbll.getLangByCode(Request.Cookies["_culture"]["lang"]);
            int InternetBankingIDs = int.Parse(System.Configuration.ConfigurationManager.AppSettings["InternetBankingID"].ToString());
            InternetBankingModels list = new InternetBankingModels();
            list = cardbll.GetInternetBankingByID(InternetBankingID, lang.LangID);
            ViewBag.FAQ = faqbll.getfaqbyproid(InternetBankingIDs, lang.LangID);
            Fcom.IDLib.SaveMoneyID.AccountsynClient client = new Fcom.IDLib.SaveMoneyID.AccountsynClient();
            FOModels.User.User us = null;
            if (User.Identity.Name != "")
            {
                Fcom.IDLib.SaveMoneyID.FullUserInfo fullinfo = client.getUserInfo(User.Identity.Name);
                us = new FOModels.User.User();
                us.DisplayName = fullinfo.Fullname;
                us.Email = fullinfo.Email;
                us.GroupID = fullinfo.GroupID;
                us.Status = fullinfo.Status;
                us.Username = fullinfo.Username;
                us.Phone = fullinfo.Phone;
                us.DOB = fullinfo.DateOfBirth;

            }
            ViewBag.UserInfo = us;


            return View(list);
        }
        public ActionResult Detail(int InternetBankingID)
        {
            InternetBankingBLL cardbll = new InternetBankingBLL();
            LanguageBLL langbll = new LanguageBLL();
            Language lang = langbll.getLangByCode(Request.Cookies["_culture"]["lang"]);
            ProductFAQBLL faqbll = new ProductFAQBLL();
            InternetBankingModels card = new InternetBankingModels();
            int InternetBankingIDs = int.Parse(System.Configuration.ConfigurationManager.AppSettings["InternetBankingID"].ToString());
            card = cardbll.GetInternetBankingByID(InternetBankingID,lang.LangID);
            ViewBag.FAQ = faqbll.getfaqbyproid(InternetBankingIDs, lang.LangID);

            return View(card);
        }
         [Authorize(Roles = "8,9")]
        public ActionResult ManagerInternetBanking()
        {
            return View();
        }
         public JsonResult getInternetBankingJson()
         {
             InternetBankingBLL cardbll = new InternetBankingBLL();
             LanguageBLL langbll = new LanguageBLL();
             Language lang = langbll.getLangByCode(Request.Cookies["_culture"]["lang"]);
             List<InternetBankingModels> list = new List<InternetBankingModels>();
             list = cardbll.GetAllToManager(lang.LangID);
             return Json(list, JsonRequestBehavior.AllowGet);
         }
        [HttpGet]
        [Authorize(Roles = "8,9")]
        public ActionResult InsertInternetBanking()
        {
            InternetBankingBLL bankingbll = new InternetBankingBLL();
            CompanyBLL bll = new CompanyBLL();
            List<CompanyModels> com = new List<CompanyModels>();
            LanguageBLL langbll = new LanguageBLL();
            Language lang = langbll.getLangByCode(Request.Cookies["_culture"]["lang"]);
            com = bll.getCompany(lang.LangID);
            ViewBag.CompanyListID = new SelectList(com, "CompanyID", "Name");
            return View();

        }
        [HttpPost]
        [Authorize(Roles = "8,9")]
        public ActionResult InsertInternetBanking(FO.Models.InternetBankingInsert banking)
        {
            LanguageBLL langbll = new LanguageBLL();
            Language lang = langbll.getLangByCode(Request.Cookies["_culture"]["lang"]);
            InternetBankingBLL cardbll = new InternetBankingBLL();
            CompanyBLL bll = new CompanyBLL();
            List<CompanyModels> com = new List<CompanyModels>();
            com = bll.getCompany(lang.LangID);
            ViewBag.CompanyListID = new SelectList(com, "CompanyID", "Name");
            if (ModelState.IsValid)
            {
                InternetBankingModels items = new InternetBankingModels();
                InternetBankingModels itemsLang = new InternetBankingModels();
                items.InternetBankingName = banking.InternetBankingName;
                items.BenefitContent = WebUtility.HtmlEncode(banking.BenefitContent);
                items.Description = WebUtility.HtmlEncode(banking.Description);
                items.FurtureContent = WebUtility.HtmlEncode(banking.FurtureContent);
                items.MoreFee = WebUtility.HtmlEncode(banking.MoreFee);
                items.MoreInfo = WebUtility.HtmlEncode(banking.MoreInfo);
                items.MoreBenefit = WebUtility.HtmlEncode(banking.MoreBenefit);
                items.CompanyID = banking.CompanyID;
                items.UserPost = User.Identity.Name;
                items.Cost = double.Parse(banking.Cost.Replace(".", "").Replace(".", ""));
                items.Interest = banking.Interest;
                items.Display = false;
                ////
                itemsLang.InternetBankingName = banking.InternetBankingNameLang;
                itemsLang.BenefitContent = WebUtility.HtmlEncode(banking.BenefitContentLang);
                itemsLang.Description = WebUtility.HtmlEncode(banking.DescriptionLang);
                itemsLang.FurtureContent = WebUtility.HtmlEncode(banking.FurtureContentLang);
                itemsLang.MoreFee = WebUtility.HtmlEncode(banking.MoreFeeLang);
                itemsLang.MoreInfo = WebUtility.HtmlEncode(banking.MoreInfoLang);
                itemsLang.MoreBenefit = WebUtility.HtmlEncode(banking.MoreBenefitLang);
                itemsLang.CompanyID = banking.CompanyID;
                itemsLang.UserPost = User.Identity.Name;
                itemsLang.Display = false;
                itemsLang.Cost = double.Parse(banking.Cost.Replace(".", "").Replace(".", ""));
                itemsLang.Interest = banking.Interest;
                cardbll.InsertInternetBanking(items);
                InternetBankingModels carditem = cardbll.getTOP1();
                items.InternetBankingID = carditem.InternetBankingID;
                itemsLang.InternetBankingID = carditem.InternetBankingID;
                cardbll.InsertInternetBankingLanng(items, 1);
                cardbll.InsertInternetBankingLanng(itemsLang, 2);
                return RedirectToAction("ManagerInternetBanking");
            }
            return View(banking);

        }

        [HttpGet]
        [Authorize(Roles = "8,9")]
        public ActionResult UpdateInternetBanking(int InternetBankingID)
        {
            LanguageBLL langbll = new LanguageBLL();
            Language lang = langbll.getLangByCode(Request.Cookies["_culture"]["lang"]);
            InternetBankingBLL cardbll = new InternetBankingBLL();
            CompanyBLL bll = new CompanyBLL();
            InternetBankingModels card = new InternetBankingModels();
            List<CompanyModels> com = new List<CompanyModels>();
            com = bll.getCompany(lang.LangID);
            card = cardbll.GetInternetBankingByIDToManager(InternetBankingID, lang.LangID);
            Models.InternetBanking c = new Models.InternetBanking();
            ViewBag.CompanyListID = new SelectList(com, "CompanyID", "Name", card.CompanyID);
            c.InternetBankingName = card.InternetBankingName;
            c.BenefitContent = WebUtility.HtmlDecode(card.BenefitContent);
            c.CompanyID = card.CompanyID;
            c.Description = WebUtility.HtmlDecode(card.Description);
            c.MoreFee = WebUtility.HtmlDecode(card.MoreFee);
            c.MoreInfo = WebUtility.HtmlDecode(card.MoreInfo);
            c.FurtureContent = WebUtility.HtmlDecode(card.FurtureContent);
            c.MoreBenefit = WebUtility.HtmlDecode(card.MoreBenefit);
            c.Display = card.Display;
            c.InternetBankingID = card.InternetBankingID;
            c.Cost = String.Format("{0:0,0}", card.Cost);
            c.Interest = card.Interest;
            return View(c);
        }
         [ValidateInput(false)]
         [HttpPost]
         [Authorize(Roles = "8,9")]
         public ActionResult UpdateInternetBanking(FO.Models.InternetBanking card)
         {
             LanguageBLL langbll = new LanguageBLL();
             Language lang = langbll.getLangByCode(Request.Cookies["_culture"]["lang"]);
             InternetBankingBLL cardbll = new InternetBankingBLL();

             CompanyBLL bll = new CompanyBLL();
             InternetBankingModels ca = new InternetBankingModels();
             List<CompanyModels> com = new List<CompanyModels>();
             com = bll.getCompany(lang.LangID);
             ViewBag.CompanyListID = new SelectList(com, "CompanyID", "Name", ca.CompanyID);
             ca = cardbll.GetInternetBankingByIDToManager(card.InternetBankingID, lang.LangID);
             if (ca != null)
             {
                 ca.InternetBankingName = card.InternetBankingName;
                 ca.BenefitContent = WebUtility.HtmlEncode(card.BenefitContent);
                 ca.CompanyID = card.CompanyID;
                 ca.Description = WebUtility.HtmlEncode(card.Description);
                 ca.MoreFee = WebUtility.HtmlEncode(card.MoreFee);
                 ca.MoreInfo = WebUtility.HtmlEncode(card.MoreInfo);
                 ca.FurtureContent = WebUtility.HtmlEncode(card.FurtureContent);
                 ca.MoreBenefit = WebUtility.HtmlEncode(card.MoreBenefit);
                 ca.Display = card.Display;
                 ca.InternetBankingID = card.InternetBankingID;
                 ca.UserUpdate = User.Identity.Name;
                 ca.DateUpdate = DateTime.Now.ToString();
                 ca.Cost = double.Parse(card.Cost.Replace(".", "").Replace(".", ""));
                 ca.Interest = card.Interest;
                 cardbll.UpdateInternetBanking(ca, lang.LangID);
                 return RedirectToAction("ManagerInternetBanking");
             }
             return View();


         }

         [HttpPost]
         [Authorize(Roles = "8,9")]
         public JsonResult DeleteInternetBanking(int InternetBankingID)
         {
             LanguageBLL langbll = new LanguageBLL();
             Language lang = langbll.getLangByCode(Request.Cookies["_culture"]["lang"]);
             InternetBankingBLL bll = new InternetBankingBLL();
             InternetBankingModels card = new InternetBankingModels();
             card = bll.GetInternetBankingByIDToManager(InternetBankingID, lang.LangID);
             if (card != null)
             {
                 bll.DeleteInternetBanking(card.InternetBankingID);
                 var result = new { Status = "OK" };
                 return Json(result, JsonRequestBehavior.AllowGet);
             }
             else
             {
                 var result = new { Status = "Xóa thất bại" };
                 return Json(result, JsonRequestBehavior.AllowGet);
             }

         }

         [HttpGet]
         [Authorize(Roles = "8,9")]
         public ActionResult Articles()
         {
             ProductBLL cardbll = new ProductBLL();
             LanguageBLL langbll = new LanguageBLL();
             Language lang = langbll.getLangByCode(Request.Cookies["_culture"]["lang"]);
             int InternetBankingID = int.Parse(System.Configuration.ConfigurationManager.AppSettings["InternetBankingID"].ToString());
             ProductModels card = new ProductModels();
             card = cardbll.getProductByID(InternetBankingID, lang.LangID);
             Models.Product c = new Models.Product();
             c.Description = WebUtility.HtmlDecode(card.Description);
             return View(c);
         }
         [ValidateInput(false)]
         [HttpPost]
         [Authorize(Roles = "8,9")]
         public ActionResult Articles(FO.Models.Product card)
         {

             ProductBLL cardbll = new ProductBLL();
             LanguageBLL langbll = new LanguageBLL();
             Language lang = langbll.getLangByCode(Request.Cookies["_culture"]["lang"]);
             int InternetBankingID = int.Parse(System.Configuration.ConfigurationManager.AppSettings["InternetBankingID"].ToString());
             ProductModels ca = new ProductModels();
             ca = cardbll.getProductByID(InternetBankingID, lang.LangID);
             if (ca != null)
             {
                 ca.Description = WebUtility.HtmlEncode(card.Description);
                 cardbll.UpdateProductDesriptionLang(ca, lang.LangID);
                 return RedirectToAction("ManagerInternetBanking");
             }

             return View();
         }

         [HttpGet]
         [Authorize(Roles = "8,9")]
         public ActionResult InsertFAQ()
         {

             return View();

         }
         [HttpPost]
         [Authorize(Roles = "8,9")]
         public ActionResult InsertFAQ(FO.Models.ProductFAQInsert card)
         {
             ProductFAQBLL cardbll = new ProductFAQBLL();
             LanguageBLL langbll = new LanguageBLL();
             Language lang = langbll.getLangByCode(Request.Cookies["_culture"]["lang"]);
             int InternetBankingID = int.Parse(System.Configuration.ConfigurationManager.AppSettings["InternetBankingID"].ToString());
             if (ModelState.IsValid)
             {
                 ProductFAQModels items = new ProductFAQModels();
                 items.FAQTitles = card.FAQTitles;
                 items.FAQAnwers = card.FAQAnwers;
                 items.ProductID = InternetBankingID;
                 cardbll.InsertFAQ(items);
                 ProductFAQModels faqitems = cardbll.gettop1faq();
                 ProductFAQModels itemsLang = new ProductFAQModels();
                 items.ProductFAQID = faqitems.ProductFAQID;
                 itemsLang.ProductFAQID = faqitems.ProductFAQID;
                 cardbll.InsertFAQLang(items, 1);

                 itemsLang.FAQTitles = card.FAQTitlesLang;
                 itemsLang.FAQAnwers = card.FAQAnwersLang;
                 cardbll.InsertFAQLang(itemsLang, 2);
                 return RedirectToAction("ManagerFAQ");
             }
             return View(card);

         }

         [HttpGet]
         [Authorize(Roles = "8,9")]
         public ActionResult UpdateFAQ(int ProductFAQID)
         {
             ProductFAQBLL cardbll = new ProductFAQBLL();
             LanguageBLL langbll = new LanguageBLL();
             Language lang = langbll.getLangByCode(Request.Cookies["_culture"]["lang"]);
             ProductFAQModels card = new ProductFAQModels();
             card = cardbll.getfaqbyid(ProductFAQID, lang.LangID);
             Models.ProductFAQ c = new Models.ProductFAQ();
             c.FAQTitles = card.FAQTitles;
             c.FAQAnwers = card.FAQAnwers;
             return View(c);
         }
         [ValidateInput(false)]
         [HttpPost]
         [Authorize(Roles = "8,9")]
         public ActionResult UpdateFAQ(FO.Models.ProductFAQ card)
         {
             ProductFAQBLL cardbll = new ProductFAQBLL();
             LanguageBLL langbll = new LanguageBLL();
             Language lang = langbll.getLangByCode(Request.Cookies["_culture"]["lang"]);
             ProductFAQModels ca = new ProductFAQModels();

             ca = cardbll.getfaqbyid(card.ProductFAQID, lang.LangID);
             if (ca != null)
             {
                 ca.FAQTitles = card.FAQTitles;
                 ca.FAQAnwers = card.FAQAnwers;
                 cardbll.UpdateFAQ(ca, lang.LangID);
                 return RedirectToAction("ManagerFAQ");
             }
             return View();


         }

         [HttpPost]
         [Authorize(Roles = "8,9")]
         public JsonResult DeleteFAQ(int ProductFAQID)
         {
             ProductFAQBLL bll = new ProductFAQBLL();
             LanguageBLL langbll = new LanguageBLL();
             ProductFAQModels card = new ProductFAQModels();

             Language lang = langbll.getLangByCode(Request.Cookies["_culture"]["lang"]);

             card = bll.getfaqbyid(ProductFAQID, lang.LangID);
             if (card != null)
             {
                 bll.DeleteFAQ(card.ProductFAQID);
                 var result = new { Status = "OK" };
                 return Json(result, JsonRequestBehavior.AllowGet);
             }
             else
             {
                 var result = new { Status = "Xóa thất bại" };
                 return Json(result, JsonRequestBehavior.AllowGet);
             }
         }
         [Authorize(Roles = "8,9")]
         public ActionResult ManagerFAQ()
         {
             return View();
         }
         public JsonResult getFAQJson()
         {
             int InternetBankingID = int.Parse(System.Configuration.ConfigurationManager.AppSettings["InternetBankingID"].ToString());
             ProductFAQBLL cardbll = new ProductFAQBLL();
             LanguageBLL langbll = new LanguageBLL();
             Language lang = langbll.getLangByCode(Request.Cookies["_culture"]["lang"]);
             List<ProductFAQModels> list = new List<ProductFAQModels>();

             list = cardbll.getfaqbyproid(InternetBankingID, lang.LangID);

             return Json(list, JsonRequestBehavior.AllowGet);
         }

         public ActionResult ThanksYou()
         {
             return View();
         }
         [HttpGet]
         [Authorize(Roles = "8,9")]
         public ActionResult ContractDetail(int InternetBankingApplyID)
         {
             InternetBankingBLL cardbll = new InternetBankingBLL();
             InternetBankingApplyModels cardapp = new InternetBankingApplyModels();
             cardapp = cardbll.getcontractbyid(InternetBankingApplyID);
             StatusBLL status = new StatusBLL();
             List<StatusModels> liststatus = new List<StatusModels>();
             liststatus = status.getStatus();
             FO.Models.InternetBankingApply c = new FO.Models.InternetBankingApply();
             ViewBag.StatusListID = new SelectList(liststatus, "StatusID", "StatusName", cardapp.StatusID);
             c.StatusID = cardapp.StatusID;
             c.CustomerName = cardapp.CustomerName;
             c.CustomerEmail = cardapp.CustomerEmail;
             c.CustomerDOB = cardapp.CustomerDOB;
             c.CustomerPhone = cardapp.CustomerPhone;
             c.CustomerIncome = cardapp.CustomerIncome;
             c.CompanyName = cardapp.CompanyName;
             c.StatusName = cardapp.StatusName;
             c.InternetBankingName = cardapp.InternetBankingName;
             c.InternetBankingID = cardapp.InternetBankingID;
             c.CompanyImg = cardapp.CompanyImg;
             c.City = cardapp.City;
             c.ContactTime = cardapp.ContactTime;
             c.BusinessLoan = cardapp.BusinessLoan;
             c.SavingsDeposits = cardapp.SavingsDeposits;
             c.HomeLoan = cardapp.HomeLoan;
             c.CarLoan = cardapp.CarLoan;
             c.PersonalLoan = cardapp.PersonalLoan;
             c.CreditCard = cardapp.CreditCard;
             c.CurrentAccount = cardapp.CurrentAccount;
             c.AppDate = cardapp.AppDate;
             return View(c);
         }
         [HttpPost]
         [ValidateInput(false)]
         [Authorize(Roles = "8,9")]
         public ActionResult ContractDetail(FO.Models.InternetBankingApply card)
         {
             InternetBankingBLL cardbll = new InternetBankingBLL();
             InternetBankingApplyModels cardapp = new InternetBankingApplyModels();
             cardapp = cardbll.getcontractbyid(card.InternetBankingApplyID);
             StatusBLL status = new StatusBLL();
             List<StatusModels> liststatus = new List<StatusModels>();
             liststatus = status.getStatus();
             ViewBag.StatusListID = new SelectList(liststatus, "StatusID", "StatusName", cardapp.StatusID);
             if (cardapp != null)
             {
                 cardapp.StatusID = card.StatusID;
                 cardbll.UpdateStatus(cardapp);
                 return RedirectToAction("Contract");
             }
             return View();
         }

         [Authorize(Roles = "8,9")]
         public ActionResult Contract()
         {
             StatusBLL status = new StatusBLL();
             List<StatusModels> liststatus = new List<StatusModels>();
             liststatus = status.getStatus();
             ViewBag.StatusID = liststatus;
             return View();
         }
         public JsonResult getContract()
         {

             InternetBankingBLL cardbll = new InternetBankingBLL();
             LanguageBLL langbll = new LanguageBLL();
             Language lang = langbll.getLangByCode(Request.Cookies["_culture"]["lang"]);
             List<InternetBankingApplyModels> list = new List<InternetBankingApplyModels>();
             list = cardbll.getcontract();
             return Json(list, JsonRequestBehavior.AllowGet);
         }

         public JsonResult getcreditcontractbystatus(int StatusID)
         {

             InternetBankingBLL cardbll = new InternetBankingBLL();
             LanguageBLL langbll = new LanguageBLL();
             Language lang = langbll.getLangByCode(Request.Cookies["_culture"]["lang"]);
             List<InternetBankingApplyModels> list = new List<InternetBankingApplyModels>();
             list = cardbll.getcontractbystatus(StatusID);
             return Json(list, JsonRequestBehavior.AllowGet);
         }
         [HttpPost]
         [Authorize(Roles = "8,9")]
         public JsonResult DeleteInternetBankingApply(int InternetBankingApplyID)
         {
             LanguageBLL langbll = new LanguageBLL();
             Language lang = langbll.getLangByCode(Request.Cookies["_culture"]["lang"]);
             InternetBankingBLL bll = new InternetBankingBLL();
             InternetBankingApplyModels card = new InternetBankingApplyModels();
             card = bll.getcontractbyid(InternetBankingApplyID);
             if (card != null)
             {
                 bll.DeleteInternetBankingApply(card.InternetBankingApplyID);
                 var result = new { Status = "OK" };
                 return Json(result, JsonRequestBehavior.AllowGet);
             }
             else
             {
                 var result = new { Status = "Xóa thất bại" };
                 return Json(result, JsonRequestBehavior.AllowGet);
             }

         }

         [HttpPost]
         public JsonResult InternetBankingApply(int InternetBankingID, string CustomerName, string CustomerEmail, string CustomerPhone, string CustomerIncome, string CustomerDOB, bool CurrentAccount, bool SavingsDeposits, bool CreditCard, bool HomeLoan, bool CarLoan, bool PersonalLoan, bool BusinessLoan, string City, string ContactTime)
         {
             LanguageBLL langbll = new LanguageBLL();
             Language lang = langbll.getLangByCode(Request.Cookies["_culture"]["lang"]);
             InternetBankingBLL bll = new InternetBankingBLL();
             InternetBankingApplyModels cardapp = new InternetBankingApplyModels();
             cardapp.InternetBankingID = InternetBankingID;
             cardapp.CustomerName = CustomerName;
             cardapp.CustomerEmail = CustomerEmail;
             cardapp.CustomerPhone = CustomerPhone;
             cardapp.CustomerIncome = CustomerIncome;
             cardapp.CustomerDOB = CustomerDOB;
             cardapp.CurrentAccount = CurrentAccount;
             cardapp.SavingsDeposits = SavingsDeposits;
             cardapp.CreditCard = CreditCard;
             cardapp.HomeLoan = HomeLoan;
             cardapp.CarLoan = CarLoan;
             cardapp.PersonalLoan = PersonalLoan;
             cardapp.BusinessLoan = BusinessLoan;
             cardapp.City = City;
             cardapp.ContactTime = ContactTime;
             cardapp.StatusID = 1;
             int result = bll.InternetBankingApply(InternetBankingID, cardapp);
             if (result == 1)
             {
                 int check = 1;
                 return Json(check);
             }
             else
             {
                 int check = -1;
                 return Json(check);
             }
         }

         public ActionResult InternetBankingsByProvider(int CompanyID)
         {
             InternetBankingBLL InternetBankingbll = new InternetBankingBLL();
             LanguageBLL langbll = new LanguageBLL();
             Language lang = langbll.getLangByCode(Request.Cookies["_culture"]["lang"]);
             ProductBLL probll = new ProductBLL();
             int InternetBankingID = int.Parse(System.Configuration.ConfigurationManager.AppSettings["InternetBankingID"].ToString());
             ViewBag.InternetBanking = InternetBankingbll.getInternetBankingbyProvider(CompanyID, lang.LangID);
             ViewBag.ProDes = probll.getProductByID(InternetBankingID, lang.LangID);
             return View();

         }

         [HttpPost]
         public ActionResult SendEmail(string Name, string phone, string emailuser, int CardID)
         {
             try
             {
                 string MailFromUserName = ConfigurationManager.AppSettings["MailFromUserName"].ToString();
                 string MailFromPassword = ConfigurationManager.AppSettings["MailFromPassword"].ToString();
                 string MailSMTP = ConfigurationManager.AppSettings["MailSMTP"].ToString();
                 string MailCC = ConfigurationManager.AppSettings["MailCC"].ToString();
                 string MailSendTo = ConfigurationManager.AppSettings["MailSendTo"].ToString();
                 Models.EmailSend email = new Models.EmailSend();
                 email.EmailSendTo = MailSendTo;
                 email.Subject = "Khách hàng " + Name + " Apply Internet Banking ID: " + CardID + "";
                 email.Body = "";
                 email.Body += "<p>Hi, Admin</p>";
                 email.Body += "<p>Khách hàng: " + Name + " Apply Internet Banking ID: " + CardID + "</p>";
                 email.Body += "<p>Email: " + emailuser + "</p>";
                 email.Body += "<p>SĐT: " + phone + "</p>";
                 email.Body += "<p><a href='http://www.vnbanknet.com/InternetBanking/ContractDetail/" + CardID + "'>Link chi tiết</a></p>";
                 email.Body += "<p>Thanks</p>";
                 MailMessage message = new MailMessage();
                 message.Body = email.Body;
                 message.IsBodyHtml = true;
                 message.From = new System.Net.Mail.MailAddress(MailFromUserName);
                 message.To.Add(email.EmailSendTo);
                 message.CC.Add(MailCC);
                 message.Subject = email.Subject;

                 System.Net.Mail.SmtpClient smtp = new System.Net.Mail.SmtpClient(MailSMTP);// you need an smtp server address to send emails
                 smtp.Credentials = new System.Net.NetworkCredential(MailFromUserName, MailFromPassword); //missing line from ur code
                 smtp.Port = 587;  //missing line from your code
                 smtp.EnableSsl = true;   //missing line from your code
                 smtp.Send(message);
                 int result = 1;
                 return Json(result, JsonRequestBehavior.AllowGet);
             }
             catch
             {
                 int result = -1;
                 return Json(result, JsonRequestBehavior.AllowGet);
             }
         }

    }
}
